package org.tiddlywiki;

import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.regex.Pattern;

import org.jsoup.nodes.Element;

public class Tiddler {
	String title = "";
	String text = "";
	String modifier = "";
	Date created;
	Date modified;
	String[] links = {};
	boolean linksUpdated = false;
	String[] tags = {};
	TiddlerField[] fields = {};

	void getFromDiv(Element div) throws ParseException {
		// Get title
		title = div.attr("title");
		// Get text
		Element pre = div.getElementsByTag("pre").first();
		text = pre.text();
		// Get date created
		DateFormat df = new SimpleDateFormat("yyyyMMddHHmm");
		created = (Date) df.parse(div.attr("created"));
		// Get date modified
		created = (Date) df.parse(div.attr("modified"));
		// Get tags
		tags = div.attr("tags").split(" ");
		// Get links
		setLinks();
		// Get fields
		
		// Get modifier
		modifier = div.attr("modifier");
		// Get links updated
	}
	
	void setLinks() {
		Pattern lnkp = Pattern.compile("\\Q[[\\E \\Q]]\\E");
		
	}
}
